package com.bigdata.appliance.controller;

import com.bigdata.appliance.common.pojo.PageResult;
import com.bigdata.appliance.service.IOrdersService;
import com.bigdata.appliance.vo.req.DoPayReqVO;
import com.bigdata.appliance.vo.req.GetBusinessmanOrderReqVO;
import com.bigdata.appliance.vo.req.PageOrdersReqVO;
import com.bigdata.appliance.vo.req.UpdateOrderStatusReqVO;
import com.bigdata.appliance.vo.resp.GetBusinessmanOrderRespVO;
import com.bigdata.appliance.vo.resp.PageOrdersRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author appliance-shop
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/api")
@Api(value = "OrdersController", tags = {"订单接口"})
@EnableTransactionManagement
public class OrdersController {

    @Resource
    private IOrdersService iOrdersService;

    @PostMapping("/uniApp/order/pay")
    @ApiOperation(value = "添加订单接口")
    public void doPay(@RequestBody @Valid DoPayReqVO vo) {
        iOrdersService.doPay(vo);
    }

    @PostMapping("/uniApp/order/status")
    @ApiOperation(value = "修改订单状态接口")
    public void updateOrderStatus(@RequestBody @Valid UpdateOrderStatusReqVO vo) {
        iOrdersService.updateOrderStatus(vo);
    }

    @PostMapping("/uniApp/order")
    @ApiOperation(value = "订单分页接口")
    public PageResult<PageOrdersRespVO> editGoods(@RequestBody @Valid PageOrdersReqVO vo) {
        return iOrdersService.pageOrders(vo);
    }

    @PostMapping("/uniApp/order/business")
    @ApiOperation(value = "商户订单接口")
    public List<GetBusinessmanOrderRespVO> editGoods(@RequestBody @Valid GetBusinessmanOrderReqVO vo) {
        return iOrdersService.getBusinessmanOrder(vo);
    }
}
